package com.example.picture;


import static com.example.picture.MusicServer.play;
import static com.example.picture.MusicServer.stop;

import android.os.Bundle;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    Gradient mGradient;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mGradient = (Gradient) findViewById(R.id.gradient);
        //创建imageview
        ImageView imageView = new ImageView(this);
        imageView.setImageResource(R.mipmap.picture1);
        ImageView imageView2 = new ImageView(this);
        imageView2.setImageResource(R.mipmap.picture2);
        ImageView imageView3 = new ImageView(this);
        imageView3.setImageResource(R.mipmap.picture3);
        ImageView imageView4 = new ImageView(this);
        imageView4.setImageResource(R.mipmap.picture4);
        ImageView imageView5 = new ImageView(this);
        imageView5.setImageResource(R.mipmap.picture5);
        ImageView imageView6 = new ImageView(this);
        imageView6.setImageResource(R.mipmap.picture6);
        ImageView imageView7 = new ImageView(this);
        imageView7.setImageResource(R.mipmap.picture7);
        List<ImageView> list = new ArrayList<>();
        list.add(imageView);
        list.add(imageView2);
        list.add(imageView3);
        list.add(imageView4);
        //设置图片即可
        mGradient.setImageViews(list);
    }
    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        stop(this);
    }


    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        play(this, R.raw.bgmusic);
    }

}